package cn.source.system.service.impl;

import cn.source.common.utils.DateUtils;
import cn.source.system.domain.DeyuDialysis;
import cn.source.system.mapper.DeyuDialysisMapper;
import cn.source.system.service.IDeyuDialysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 腹透记录Service业务层处理
 * 
 * @author deyucare.com
 * @date 2025-02-20
 */
@Service
public class DeyuDialysisServiceImpl implements IDeyuDialysisService 
{
    @Autowired
    private DeyuDialysisMapper deyuDialysisMapper;

    /**
     * 查询腹透记录
     * 
     * @param deyuDialysis 腹透记录主键
     * @return 腹透记录
     */
    @Override
    public DeyuDialysis selectDeyuDialysisById(DeyuDialysis deyuDialysis)
    {
        return deyuDialysisMapper.selectDeyuDialysisById(deyuDialysis);
    }

    /**
     * 查询腹透记录列表
     * 
     * @param deyuDialysis 腹透记录
     * @return 腹透记录
     */
    @Override
    public List<DeyuDialysis> selectDeyuDialysisList(DeyuDialysis deyuDialysis)
    {
        return deyuDialysisMapper.selectDeyuDialysisList(deyuDialysis);
    }

    /**
     * 新增腹透记录
     * 
     * @param deyuDialysis 腹透记录
     * @return 结果
     */
    @Override
    public int insertDeyuDialysis(DeyuDialysis deyuDialysis)
    {
        deyuDialysis.setCreateTime(DateUtils.getNowDate());
        return deyuDialysisMapper.insertDeyuDialysis(deyuDialysis);
    }

    /**
     * 修改腹透记录
     * 
     * @param deyuDialysis 腹透记录
     * @return 结果
     */
    @Override
    public int updateDeyuDialysis(DeyuDialysis deyuDialysis)
    {
        deyuDialysis.setUpdateTime(DateUtils.getNowDate());
        return deyuDialysisMapper.updateDeyuDialysis(deyuDialysis);
    }

    /**
     * 批量删除腹透记录
     * 
     * @param ids 需要删除的腹透记录主键
     * @return 结果
     */
    @Override
    public int deleteDeyuDialysisByIds(Long[] ids)
    {
        return deyuDialysisMapper.deleteDeyuDialysisByIds(ids);
    }

    /**
     * 删除腹透记录信息
     * 
     * @param id 腹透记录主键
     * @return 结果
     */
    @Override
    public int deleteDeyuDialysisById(Long id)
    {
        return deyuDialysisMapper.deleteDeyuDialysisById(id);
    }

    /**
     * 批量插入腹透记录
     *
     * @param deyuDialysisList 批量插入腹透记录
     * @return 结果
     */
    @Override
    public int insertBatchDeyuDialysis(List<DeyuDialysis> deyuDialysisList) {
        return deyuDialysisMapper.insertBatch(deyuDialysisList);
    }

    @Override
    public Long getNearlyAWeekOfRisk(Long userId) {
        return deyuDialysisMapper.getNearlyAWeekOfRisk(userId);
    }

    @Override
    public List<DeyuDialysis> summaryByDay(DeyuDialysis dialysis) {
        return deyuDialysisMapper.summaryByDay(dialysis);
    }

    @Override
    public int updateForCompletedTime(DeyuDialysis dialysis) {
        dialysis.setCreateTime(DateUtils.getNowDate());
        return deyuDialysisMapper.updateForCompletedTime(dialysis);
    }
}
